<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddIsFinishFoodsToWaimaiOrders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 分表库
        for ($i = 0; $i <= 99; $i++) {
            $this->name = '_' . str_pad($i, 3, 0, STR_PAD_LEFT);
            Schema::connection("mysqlWaiMai")->table('waimai_orders' . $this->name, function (Blueprint $table) {
                $table->unsignedTinyInteger('isFinishFoods')->default(0)->comment('是否出餐 0否 1是');
            });

            dump($this->name);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // 分表库
        for ($i = 0; $i <= 99; $i++) {
            $this->name = '_' . str_pad($i, 3, 0, STR_PAD_LEFT);
            Schema::connection("mysqlWaiMai")->table('waimai_orders' . $this->name, function (Blueprint $table) {
                $table->dropColumn('isFinishFoods');
            });

            dump($this->name);
        }
    }
}
